package com.cmict.data.bpm.dal.mysql.externalfile;

import com.cmict.data.bpm.controller.admin.externalfile.vo.ExternalFileExportReqVO;
import com.cmict.data.bpm.controller.admin.externalfile.vo.ExternalFilePageReqVO;
import com.cmict.data.bpm.dal.dataobject.externalfile.ExternalFileDO;
import com.cmict.data.framework.common.pojo.PageResult;
import com.cmict.data.framework.mybatis.core.mapper.BaseMapperX;
import com.cmict.data.framework.mybatis.core.query.LambdaQueryWrapperX;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 工作流审批附件 Mapper
 */
@Mapper
public interface ExternalFileMapper extends BaseMapperX<ExternalFileDO> {

    default PageResult<ExternalFileDO> selectPage(ExternalFilePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ExternalFileDO>()
                .likeIfPresent(ExternalFileDO::getName, reqVO.getName())
                .eqIfPresent(ExternalFileDO::getProcessInstanceId, reqVO.getProcessInstanceId())
                .eqIfPresent(ExternalFileDO::getTaskId, reqVO.getTaskId())
                .eqIfPresent(ExternalFileDO::getType, reqVO.getType())
                .eqIfPresent(ExternalFileDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(ExternalFileDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(ExternalFileDO::getId));
    }

    default List<ExternalFileDO> selectList(ExternalFileExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ExternalFileDO>()
                .likeIfPresent(ExternalFileDO::getName, reqVO.getName())
                .eqIfPresent(ExternalFileDO::getProcessInstanceId, reqVO.getProcessInstanceId())
                .eqIfPresent(ExternalFileDO::getTaskId, reqVO.getTaskId())
                .eqIfPresent(ExternalFileDO::getType, reqVO.getType())
                .eqIfPresent(ExternalFileDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(ExternalFileDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(ExternalFileDO::getId));
    }

}
